<?php
class lazyLoad extends CWidget
{
	protected $cs;
	protected $assetUrl;

	public function init(){
		$this->cs = Yii::app()->clientScript;
		$this->assetUrl = Yii::app()->assetManager->publish(dirname(__FILE__).'/asset');
		$this->regFiles();
		parent::init();
	}

	public function run(){
		$this->cs->registerScript(__CLASS__,"
			$('.goods img').lazyload({
				placeholder:'".$this->assetUrl.'/grey.gif'."',
				effect: 'fadeIn'
			});
		");
	}

	protected function regFiles(){
		$this->cs->registerScriptFile($this->assetUrl.'/jquery.lazyload.mini.js');
	}
}